// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   CommPortIdentifier.java

package javax.comm;

// Referenced classes of package javax.comm:
//            CommPortEnumerator, CommPortIdentifier, CommPortOwnershipListener, CpoListEntry, 
//            OwnershipEventThread

class CpoList
{

    CpoListEntry listHead;

    synchronized void add(CommPortOwnershipListener commportownershiplistener)
    {
        for(CpoListEntry cpolistentry = listHead; cpolistentry != null; cpolistentry = cpolistentry.next)
            if(cpolistentry.listener == commportownershiplistener)
                return;

        CpoListEntry cpolistentry1 = new CpoListEntry(commportownershiplistener);
        cpolistentry1.next = listHead;
        listHead = cpolistentry1;
    }

    synchronized void remove(CommPortOwnershipListener commportownershiplistener)
    {
        CpoListEntry cpolistentry = null;
        for(CpoListEntry cpolistentry1 = listHead; cpolistentry1 != null; cpolistentry1 = cpolistentry1.next)
        {
            if(cpolistentry1.listener == commportownershiplistener)
            {
                if(cpolistentry != null)
                    cpolistentry.next = cpolistentry1.next;
                else
                    listHead = cpolistentry1.next;
                cpolistentry1.listener = null;
                cpolistentry1.next = null;
                return;
            }
            cpolistentry = cpolistentry1;
        }

    }

    synchronized CpoList clonelist()
    {
        CpoListEntry cpolistentry = null;
        Object obj = null;
        for(CpoListEntry cpolistentry2 = listHead; cpolistentry2 != null; cpolistentry2 = cpolistentry2.next)
        {
            CpoListEntry cpolistentry1 = new CpoListEntry(cpolistentry2.listener);
            cpolistentry1.next = cpolistentry;
            cpolistentry = cpolistentry1;
        }

        CpoList cpolist = new CpoList();
        cpolist.listHead = cpolistentry;
        return cpolist;
    }

    synchronized boolean isEmpty()
    {
        return listHead == null;
    }

    synchronized void fireOwnershipEvent(int i)
    {
        for(CpoListEntry cpolistentry = listHead; cpolistentry != null; cpolistentry = cpolistentry.next)
            cpolistentry.listener.ownershipChange(i);

    }

    synchronized void dump()
    {
        for(CpoListEntry cpolistentry = listHead; cpolistentry != null; cpolistentry = cpolistentry.next)
            System.err.println("    CpoListEntry - " + cpolistentry.listener.toString());

    }

    CpoList()
    {
    }
}
